<template>
    <div >
      <el-container  style="height: 752px">
        <!--左边导航栏-->
        <el-aside width="auto">

          <!--<el-radio-group v-model="isCollapse" style="margin-bottom: 20px;">-->
            <!--<el-radio-button :label="false">展开</el-radio-button>-->
            <!--<el-radio-button :label="true">收起</el-radio-button>-->
          <!--</el-radio-group>-->





          <el-menu background-color="#304156" text-color="#BFCBD9" active-text-color="#BFCBD9" default-active="1-4-1" class="el-menu-vertical-demo" @select="handleSelect" @open="handleOpen" @close="handleClose" :collapse="isCollapse" >
            <el-submenu :index="index" v-for="menu,index in rightmenu">

              <template slot="title">
                <i :class="menu.tubiao"></i>
                <span slot="title">{{menu.firstmenu}}</span>
              </template>

              <el-menu-item-group >
                <el-menu-item :index="mm.sonindex" v-for="mm in menu.sonmenu">{{mm.sonname}}</el-menu-item>

              </el-menu-item-group>
            </el-submenu>


          </el-menu>

        </el-aside>

        <el-container>
          <!--右边头部-->
          <el-header>
            <div>
            <i class="el-icon-menu" @click="isCollapsetype()" style="font-size: 30px;margin-top: 10px;float: left;color: dodgerblue"></i>
            </div>
            <div style="margin-left: 50px;margin-top: 20px;width: 1000px;height: 40px">

              <el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab" @tab-click="changeMenu">
                <el-tab-pane
                  v-for="(item, index) in editableTabs"
                  :key="item.name"
                  :label="item.title"
                  :name="item.name"
                >
                  {{ item.content }}
                </el-tab-pane>
              </el-tabs>


            </div>

            </el-header>
          <!--放每个vue组件-->
          <el-main>Main</el-main>
        </el-container>
      </el-container>

    </div>
</template>

<script>
    export default {
        name: "HTindex",
      data(){
          return{
            isCollapse: false,
            rightmenu:[
              {firstmenu:"常用功能",tubiao:"el-icon-s-platform",sonmenu:[
                                                                                          {sonindex:"1-1",sonname:"课程订单"}
                                                                                          ]},
              {firstmenu:"首页管理",tubiao:"el-icon-s-unfold",sonmenu:[
                  {sonindex:"2-1",sonname:"头部导航"},
                  {sonindex:"2-2",sonname:"轮播管理"}
                ]},
              {firstmenu:"课程管理",tubiao:"el-icon-s-open",sonmenu:[
                  {sonindex:"3-1",sonname:"课程列表"},
                  {sonindex:"3-2",sonname:"课程审核"},
                  {sonindex:"3-3",sonname:"分类管理"},
                ]},
              {firstmenu:"讲师管理",tubiao:"el-icon-s-comment",sonmenu:[
                  {sonindex:"4-1",sonname:"讲师列表"},
                  {sonindex:"4-1",sonname:"讲师审核"},
                  {sonindex:"4-1",sonname:"分润列表"},
                ]},
              {firstmenu:"学院管理",tubiao:"el-icon-s-data",sonmenu:[
                  {sonindex:"5-1",sonname:"学院管理"},
                ]},
              {firstmenu:"权限管理",tubiao:"el-icon-s-check",sonmenu:[
                  {sonindex:"6-1",sonname:"权限管理"},
                  {sonindex:"6-2",sonname:"角色管理"},
                  {sonindex:"6-3",sonname:"菜单管理"},
                ]},
              ],
            dynamicTags: ['标签一'],
            inputVisible: false,
            inputValue: '',


            //标签页相关数据----start
            editableTabsValue: '1',
            editableTabs: [
              {title: 'Tab 1',
                name: '1',
                content: 'Tab 1 content'
              },
              // {
              //   title: 'Tab 2',
              //   name: '2',
              //   content: 'Tab 2 content'
              // }
            ],
            tabIndex: 2
          }
      },
      methods:{
        handleOpen(key, keyPath) {

        },
        handleClose(key, keyPath) {

        },

        isCollapsetype(){
          if (this.isCollapse) {
            this.isCollapse=false;
          }else {
            this.isCollapse=true;
          }
        },
        //标签页相关方法
        removeTab(targetName) {
          let tabs = this.editableTabs;
          let activeName = this.editableTabsValue;
          if (activeName === targetName) {
            tabs.forEach((tab, index) => {
              if (tab.name === targetName) {
                let nextTab = tabs[index + 1] || tabs[index - 1];
                if (nextTab) {
                  activeName = nextTab.name;
                }
              }
            });
          }
          this.editableTabsValue = activeName;
          this.editableTabs = tabs.filter(tab => tab.name !== targetName);
        },
        /**
         *  右侧横向菜单栏被选中时
         * @param key
         * @param keyPath
         */
        handleSelect(key, keyPath){
          console.log(key, keyPath);
          // this.showBreadcrumbs(key);
          console.log(this.editableTabs);
          let status = 0;
          this.editableTabs.some(item =>{
            if( item.name == key ){
              this.editableTabsValue = key;
              status = 1;
              return true;
            }
          });
          console.log(status);
          if(status == 0){
            this.editableTabsValue = key;
            let t1 = new Object();
            t1.title = key;
            t1.name = key;
            this.editableTabs.push(t1);
          }

        },



      }
    }
</script>

<style scoped>

  .el-header {
    background-color: #B3C0D1;
  }

  .el-aside {
    background-color: #304156;
    text-align: center;
  }

  .el-main {
    background-color: #E9EEF3;
    text-align: center;
  }

  body > .el-container {
    margin-bottom: 40px;
    height: 100%;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
  }

  .el-container:nth-child(7) .el-aside {

  }


  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 180px;
    min-height: 100%;
    background-color:#304156;
  }

  .el-menu-item{
    color: #BFCBD9;
  }

  .el-tag + .el-tag {
    margin-left: 10px;
  }
  .button-new-tag {
    margin-left: 10px;
    height: 32px;
    line-height: 30px;
    padding-top: 0;
    padding-bottom: 0;
  }


</style>
